public class Solution {
    public int missingNumber(int[] nums) {
        int n = nums.length;
        int vsum = (1 + n) * n / 2;
        int rsum = 0;

        for (int i = 0; i < nums.length; i++) {
            rsum += nums[i];
        }

       return vsum - rsum;
    }
}
